home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / lastcall.dxr / 00004_Soda dispenser behavior.ls < prev    next >
Encoding:
Text File  |  2000-03-27  |  3.1 KB  |  153 lines

  1. property pSpr, pSodaFlavor, pFlavors, pHoseSprite, pTilt, pTimer, pPickItUp, pDraggingMember, pOrigMember
  2. global gSodaGunPopup
  3.  
  4. on beginSprite me
  5.   global gSodaIngredientsList
  6.   pSpr = sprite(me.spriteNum)
  7.   pFlavors = gSodaIngredientsList
  8.   pHoseSprite = sprite(me.spriteNum - 1)
  9.   pSodaFlavor = #water
  10.   pOrigMember = pSpr.member
  11.   pDraggingMember = nextMember(pOrigMember)
  12.   pTilt = #left
  13. end
  14.  
  15. on mouseEnter me
  16.   if not draggingAnything() then
  17.     pTimer = nowTicks()
  18.     showToolTip(pSpr, customToolTip(me))
  19.   end if
  20. end
  21.  
  22. on rightMouseDown me
  23.   if the stage = the activeWindow then
  24.     pMouseLoc = the clickLoc
  25.     sendSprite(gSodaGunPopup, #mShowPopup, pSpr)
  26.   end if
  27. end
  28.  
  29. on mouseUp me
  30.   if the doubleClick then
  31.     exit
  32.   end if
  33.   startedAt = nowTicks()
  34.   repeat while ticksSince(startedAt) < 20
  35.     if the mouseDown then
  36.       exit
  37.     end if
  38.   end repeat
  39.   if pPickItUp then
  40.     pSpr.visible = 0
  41.     mPickMeUp(me)
  42.   end if
  43. end
  44.  
  45. on mPickMeUp me, noToolTip, pickupLoc
  46.   global gFloatSprite
  47.   wasVis = pHoseSprite.visible
  48.   pHoseSprite.visible = 0
  49.   if wasVis then
  50.     replaceDraggingAnything()
  51.   end if
  52.   returnToBar(VOID, 1)
  53.   sendSprite(gFloatSprite, #mPickUpBottle, pSpr, VOID, VOID, pSodaFlavor, mGetPourSound(me), VOID, pickupLoc)
  54. end
  55.  
  56. on mouseDown
  57.   pPickItUp = 1
  58.   if the doubleClick then
  59.     repeat while the stillDown
  60.       checkElapsedTime()
  61.       updateStage()
  62.     end repeat
  63.     goSoda()
  64.   else
  65.     if draggingAnything() then
  66.       replaceDraggingAnything()
  67.       exit
  68.     end if
  69.     if modifierDown() then
  70.       pMouseLoc = the clickLoc
  71.       sendSprite(gSodaGunPopup, #mShowPopup, pSpr)
  72.       exit
  73.     end if
  74.     menuDown = nowTicks()
  75.     repeat while the stillDown
  76.       checkElapsedTime()
  77.       updateStage()
  78.       if ticksSince(menuDown) > 30 then
  79.         goSoda()
  80.         exit
  81.       end if
  82.     end repeat
  83.   end if
  84. end
  85.  
  86. on mGetPourSound me
  87.   return VOID
  88. end
  89.  
  90. on mouseLeave me
  91.   if not draggingAnything() then
  92.     hideToolTip()
  93.   end if
  94. end
  95.  
  96. on mReplaceIt me
  97.   pPickItUp = 0
  98.   pSpr.visible = 1
  99.   pHoseSprite.visible = 1
  100. end
  101.  
  102. on mChangeSoda me, newFlavorInput, blipMe
  103.   global gSodaAlerts, gSodaText, gUsedSoda
  104.   gUsedSoda = 1
  105.   oldFlavor = pSodaFlavor
  106.   if voidp(getaProp(pFlavors, newFlavorInput)) then
  107.     foundit = 0
  108.     repeat with X = 1 to count(pFlavors)
  109.       if pFlavors[X][#key] = newFlavorInput then
  110.         foundit = 1
  111.         exit repeat
  112.       end if
  113.     end repeat
  114.     if foundit then
  115.       pSodaFlavor = getPropAt(pFlavors, X)
  116.     end if
  117.   else
  118.     pSodaFlavor = newFlavorInput
  119.   end if
  120.   if pSodaFlavor <> oldFlavor then
  121.     sendSprite(gSodaText, #mChangeText, pSodaFlavor)
  122.     refreshHelpWindow(pSodaFlavor)
  123.     showToolTip(pSpr, pSodaFlavor)
  124.   end if
  125.   if gSodaAlerts[pSodaFlavor] = 1 then
  126.     gSodaAlerts[pSodaFlavor] = 2
  127.   end if
  128.   if blipMe then
  129.     forceToolTip(pSpr, pSodaFlavor, pSpr.loc)
  130.   end if
  131.   mPickMeUp(me)
  132. end
  133.  
  134. on mouseWithin me
  135.   if draggingAnything() then
  136.   else
  137.     if tipTickRange(pTimer) then
  138.       forceToolTip(pSpr, customToolTip(me))
  139.     else
  140.       dismissToolTip()
  141.     end if
  142.   end if
  143. end
  144.  
  145. on customToolTip me
  146.   global gHelpPointer
  147.   if modifierDown() or not gHelpPointer then
  148.     return pSodaFlavor
  149.   else
  150.     return #sodagun
  151.   end if
  152. end
  153.